package com.vmj.instructions.math;

import com.vmj.instructions.base.NoOperandsInstruction;
import com.vmj.rtda.Frame;
import com.vmj.rtda.OperandStack;

/**
 * Created by yangshoujun on 2017/9/17 上午12:02.
 */
public class Idiv extends NoOperandsInstruction{
    @Override
    public void execute(Frame frame) {
        OperandStack stack = frame.getOperandStack();
        int v2 = stack.popInt();
        int v1 = stack.popInt();
        if(v2 == 0) {
            throw new RuntimeException("java.lang.ArithmeticException: / by zero");
        }

        int val = v1 / v2;
        stack.pushInt(val);
    }
}
